<?php
$table[1] = 'table_1';
$table[2] = 'table_2';
$table[3] = 'table_3';
$table[4] = 'table_4';
$table[5] = 'table_5';
$table[6] = 'table_6';
echo("NABTON Benny1");
    if ($db = new SQLite3('nabton/NDSCollector/target/NDSControl.db')) 
    {
echo("NABTON Benny2");
      for($ii = 1; $ii<6;$ii++)
      {
	 
        $q = $db->exec("SELECT tag FROM $table[$ii]");
        if ($q === false) 
        {
            $db->exec("CREATE TABLE $table[$ii] (tag text, value int,status text, create_time text, description text, PRIMARY KEY (create_time))");
            echo("Table $ii created<br>");
        } 
        else 
        {
             echo("Table $ii already exists<br>");
        }

        $db->exec("INSERT INTO $table[$ii] VALUES ('HB_VAL',60,'NEW','2014','test')");
      }
    } 
    else 
    {
        echo("Die!<br>");
        //die($err);
    }
    echo("NABTON Benny3");
?>
